﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.EmphasizeContinuousMfg.CApECMEmphasizingModel
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.Generic;
using System.Collections.ObjectModel;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.EmphasizeContinuousMfg;

internal class CApECMEmphasizingModel
{
  private static CApECMEmphasizingModel m_instance;
  private Dictionary<TxSeamMfgFeature, CApECMContinuousMfgItem> m_mfgToItem;
  private int m_currentWidth;
  private TxColor m_currentColor;
  private int m_defaultWidth;
  private TxColor m_defaultColor;
  private bool m_doesHaveColorDefault = true;
  private bool m_doesHaveColorCurrent = true;

  internal static CApECMEmphasizingModel Instance => CApECMEmphasizingModel.m_instance;

  public int CurrentWidth
  {
    get => this.m_currentWidth;
    set => this.m_currentWidth = value;
  }

  public int DefaultWidth
  {
    get
    {
      this.m_defaultWidth = CApECMEmphasizingManager.GetWidthFromOptions();
      return this.m_defaultWidth;
    }
  }

  public TxColor CurrentColor
  {
    get => this.m_currentColor;
    set => this.m_currentColor = value;
  }

  public TxColor DefaultColor
  {
    get
    {
      this.m_defaultColor = CApECMEmphasizingManager.GetColorFromOptions();
      return this.m_defaultColor;
    }
    set => this.m_defaultColor = value;
  }

  public bool DoesHaveDefaultColor
  {
    get
    {
      this.m_doesHaveColorDefault = CApECMEmphasizingManager.GetConsiderColorFromOptions();
      return this.m_doesHaveColorDefault;
    }
    set => this.m_doesHaveColorDefault = value;
  }

  public bool DoesHaveCurrentColor
  {
    get => this.m_doesHaveColorCurrent;
    set => this.m_doesHaveColorCurrent = value;
  }

  internal Dictionary<TxSeamMfgFeature, CApECMContinuousMfgItem> MfgToItem => this.m_mfgToItem;

  private CApECMEmphasizingModel()
  {
    this.m_mfgToItem = new Dictionary<TxSeamMfgFeature, CApECMContinuousMfgItem>();
    this.InitializeModelItems();
  }

  private void InitializeModelItems()
  {
    TxTypeFilter txTypeFilter = new TxTypeFilter();
    txTypeFilter.AddIncludedType(typeof (TxSeamMfgFeature));
    foreach (ITxObject allDescendant in (Collection<ITxObject>) TxApplication.ActiveDocument.MfgRoot.GetAllDescendants((ITxTypeFilter) txTypeFilter))
    {
      TxSeamMfgFeature seamMfg = allDescendant as TxSeamMfgFeature;
      if (TxSeamMfgFeature.op_Inequality(seamMfg, (ITxObject) null))
        this.AddMfgItem(seamMfg);
    }
  }

  public static CApECMEmphasizingModel Initialize(
    int defaultWidth,
    TxColor defaultColor,
    bool doesHaveColorDefault)
  {
    CApECMEmphasizingModel.m_instance = new CApECMEmphasizingModel();
    CApECMEmphasizingModel.m_instance.m_currentWidth = CApECMEmphasizingModel.m_instance.m_defaultWidth = defaultWidth;
    CApECMEmphasizingModel.m_instance.m_currentColor = CApECMEmphasizingModel.m_instance.m_defaultColor = defaultColor;
    CApECMEmphasizingModel.m_instance.m_doesHaveColorCurrent = CApECMEmphasizingModel.m_instance.m_doesHaveColorDefault = doesHaveColorDefault;
    return CApECMEmphasizingModel.Instance;
  }

  public static void DisposeSingleton()
  {
    CApECMEmphasizingModel.m_instance = (CApECMEmphasizingModel) null;
  }

  public void AddMfgItem(TxSeamMfgFeature seamMfg)
  {
    CApECMContinuousMfgItem continuousMfgItem = CApECMContinuousMfgItemsFactory.MakeContinuousMfgItem(seamMfg);
    if (continuousMfgItem == null)
      return;
    this.m_mfgToItem.Add(seamMfg, continuousMfgItem);
  }

  public void RemoveMfgItem(TxSeamMfgFeature seamMfg)
  {
    if (this.m_mfgToItem == null || !this.m_mfgToItem.ContainsKey(seamMfg))
      return;
    this.m_mfgToItem.Remove(seamMfg);
  }

  public CApECMContinuousMfgItem GetMfgItemFromMfg(TxSeamMfgFeature seamMfg)
  {
    CApECMContinuousMfgItem mfgItemFromMfg = (CApECMContinuousMfgItem) null;
    if (this.m_mfgToItem != null && this.m_mfgToItem.ContainsKey(seamMfg))
      mfgItemFromMfg = this.m_mfgToItem[seamMfg];
    return mfgItemFromMfg;
  }

  internal void ResetToDefaultColor()
  {
    this.CurrentColor = this.DefaultColor;
    this.DoesHaveCurrentColor = this.DoesHaveDefaultColor;
  }

  internal void ResetToDefaultWidth() => this.CurrentWidth = this.DefaultWidth;
}
